import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TemplateUsageVO, TemplateUsageForm, TemplateUsageQuery } from '@/api/logic/templateUsage/types';

/**
 * 查询模版使用管理列表
 * @param query
 * @returns {*}
 */

export const listTemplateUsage = (query?: TemplateUsageQuery): AxiosPromise<TemplateUsageVO[]> => {
  return request({
    url: '/logic/templateUsage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询模版使用管理详细
 * @param usageId
 */
export const getTemplateUsage = (usageId: string | number): AxiosPromise<TemplateUsageVO> => {
  return request({
    url: '/logic/templateUsage/' + usageId,
    method: 'get'
  });
};

/**
 * 新增模版使用管理
 * @param data
 */
export const addTemplateUsage = (data: TemplateUsageForm) => {
  return request({
    url: '/logic/templateUsage',
    method: 'post',
    data: data
  });
};

/**
 * 修改模版使用管理
 * @param data
 */
export const updateTemplateUsage = (data: TemplateUsageForm) => {
  return request({
    url: '/logic/templateUsage',
    method: 'put',
    data: data
  });
};

/**
 * 删除模版使用管理
 * @param usageId
 */
export const delTemplateUsage = (usageId: string | number | Array<string | number>) => {
  return request({
    url: '/logic/templateUsage/' + usageId,
    method: 'delete'
  });
};
